<?php
error_reporting(0);

$conn = mysql_connect('localhost', 'root', 'EXgY7qXZz+bxkCW78470.b1fsi3+K4') or die('Can\'t connect');
$serverset = "character_set_connection='utf8',character_set_results='utf8',character_set_client=binary, sql_mode=''";
mysql_query($serverset, $conn);
mysql_select_db('test');

if($_GET['a'] == 'set') {
    $dirname = intval($_GET['dirname']);
    if($dirname < 1 || $dirname > 11) exit;
    if(!in_array($_GET['ab'], array('a', 'b', ''))) exit;
    $qz = intval($_GET['qz']);
    mysql_query("UPDATE `check` SET ab='{$_GET['ab']}',weight={$qz},mtime='".date('Y-m-d H:i:s')."' WHERE dirname=$dirname");
    echo mysql_error();
} else {
    $res = mysql_query("SELECT * FROM `check`");
    $data = array();
    while($r = mysql_fetch_assoc($res)) {
        $data[] = $r;
    }

    echo json_encode($data);
}

mysql_close();